<template>
   <div id="reportContainer"></div>
</template>

<script>
import * as pbi from 'powerbi-client';
import { getAgentReport } from "@/api/marketingStat/agentReport";
import { getDeptId } from '@/utils/auth'

export default {
  name: "agentReport",
  data() {
    return {
    };
  },
  created() {
    getAgentReport({
     groupId: "21c33949-7cda-4625-b204-42147e66362e",
     reportId: "a89fa135-d927-4fec-8ea3-bae47ec41807"
    }).then(res => {
				// Read embed URL from Model
				var embedUrl =
					"https://app.powerbi.cn/reportEmbed?reportId=a89fa135-d927-4fec-8ea3-bae47ec41807&groupId=21c33949-7cda-4625-b204-42147e66362e&filter=city/city_id eq "+ getDeptId();

				// embedUrl+&autoAuth=true 可登录用户名密码直接访问    embedUrl+&filter=Table/Field eq 'value'  可传入筛选器 ，详见https://docs.microsoft.com/zh-cn/power-bi/service-url-filters

				// Read report Id from Model
				var embedReportId = "a89fa135-d927-4fec-8ea3-bae47ec41807";
				// Get models. models contains enums that can be used.
				// var models = window['powerbi-client'].models;
				// Embed configuration used to describe the what and how to embed.
				// This object is used when calling powerbi.embed.
				// This also includes settings and options such as filters.
				// You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
				// const basicFilter: pbi.models.IBasicFilter = {
				// $schema: "http://powerbi.com/product/schema#basic",
				// target: {
				//   table: "syb",
				//   column: "syb_id"
				// },
				// operator: "In",
				// values: ['87603'],
				// filterType: 1 // pbi.models.FilterType.BasicFilter,
				// requireSingleSelection: true // Limits selection of values to one.
				// }
				var config = {
					type: 'report',
					tokenType: pbi.models.TokenType.Embed,
					accessToken: res.data,
					embedUrl: embedUrl,
					// id: embedReportId,
					viewMode: pbi.models.ViewMode.View,
					// filters: basicFilter,
					permissions: pbi.models.Permissions.All,
					settings: {
						filterPaneEnabled: false,
						navContentPaneEnabled: false
					}
					// 底边栏和侧边栏   不显示
				};

        var report = powerbi.embed(document.querySelector('#reportContainer'), config);
    })
  }
};
</script>

<style lang="scss">
#reportContainer {
  width: 100%;
  height: calc(100vh - 100px)
}
</style>
